﻿#region Header
// Copyright 2007-2011, Jerónimo Milea
// 
// This file is part of NetJsWire.
// 
//     NetJsWire is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
// 
//     NetJsWire is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
// 
//     You should have received a copy of the GNU General Public License
//     along with NetJsWire.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using NetJsWire.JsonRpcHandler;

namespace NetJsWire.Widgets.Core
{
    /// <summary>
    ///   Class used to show unobtrusive messages to the user.
    /// </summary>
    public static class Message
    {
        /// <summary>
        ///   Show a message.
        /// </summary>
        /// <param name = "content">The message to show.</param>
        public static void Show( string content )
        {
            WebApplication.Instance.AddChange( string.Format( "NetJsWire.msg(\"System\", \"{0}\");", content ) );
        }

        /// <summary>
        ///   Show a message.
        /// </summary>
        /// <param name = "content">The message to show</param>
        /// <param name = "type">The type of icon the message will show.</param>
        public static void Show( string content, MessageType type )
        {
            WebApplication.Instance.AddChange( string.Format( "NetJsWire.msg(\"System\", \"{0}\", 2, {1});", content,
                                                              ( int ) type ) );
        }

        /// <summary>
        ///   Show a message.
        /// </summary>
        /// <param name = "content">The message to show</param>
        /// <param name = "duration">The duration of the message in seconds (default is 2).</param>
        public static void Show( string content, int duration )
        {
            WebApplication.Instance.AddChange( string.Format( "NetJsWire.msg(\"System\", \"{0}\", {1});", content,
                                                              duration ) );
        }

        /// <summary>
        ///   Show a message.
        /// </summary>
        /// <param name = "content">The message to show</param>
        /// <param name = "duration">The duration of the message in seconds (default is 2).</param>
        /// <param name = "type">The type of icon the message will show.</param>
        public static void Show( string content, int duration, MessageType type )
        {
            WebApplication.Instance.AddChange( string.Format( "NetJsWire.msg(\"System\", \"{0}\", {1}, {2});", content,
                                                              duration, ( int ) type ) );
        }

        /// <summary>
        ///   Show a message.
        /// </summary>
        /// <param name = "title">The title of the message (default is System).</param>
        /// <param name = "content">The message to show</param>
        public static void Show( string title, string content )
        {
            WebApplication.Instance.AddChange( string.Format( "NetJsWire.msg(\"{0}\", \"{1}\");", title, content ) );
        }

        /// <summary>
        ///   Show a message.
        /// </summary>
        /// <param name = "title">The title of the message (default is System).</param>
        /// <param name = "content">The message to show</param>
        /// <param name = "type">The type of icon the message will show.</param>
        public static void Show( string title, string content, MessageType type )
        {
            WebApplication.Instance.AddChange( string.Format( "NetJsWire.msg(\"{0}\", \"{1}\", 2, {2});", title, content,
                                                              ( int ) type ) );
        }

        /// <summary>
        ///   Show a message.
        /// </summary>
        /// <param name = "title">The title of the message (default is System).</param>
        /// <param name = "content">The message to show</param>
        /// <param name = "duration">The duration of the message in seconds (default is 2).</param>
        public static void Show( string title, string content, int duration )
        {
            WebApplication.Instance.AddChange( string.Format( "NetJsWire.msg(\"{0}\", \"{1}\", {2});", title, content,
                                                              duration ) );
        }

        /// <summary>
        ///   Show a message.
        /// </summary>
        /// <param name = "title">The title of the message (default is System).</param>
        /// <param name = "content">The message to show</param>
        /// <param name = "duration">The duration of the message in seconds (default is 2).</param>
        /// <param name = "type">The type of icon the message will show.</param>
        public static void Show( string title, string content, int duration, MessageType type )
        {
            WebApplication.Instance.AddChange( string.Format( "NetJsWire.msg(\"{0}\", \"{1}\", {2}, {3});", title,
                                                              content, duration, ( int ) type ) );
        }
    }
}